package com.hhtc.jsj.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hhtc.jsj.common.response.Result;
import com.hhtc.jsj.request.PostRequest;
import com.hhtc.jsj.request.UserRequest;
import com.hhtc.jsj.service.PostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 帖子表 前端控制器
 * </p>
 *
 * @author ty
 * @since 2022-04-07
 */
@RestController
@RequestMapping("/post")
public class PostController {
    @Autowired
    private PostService postService;
    @PostMapping(value = "/add")
    public Result add(@RequestBody PostRequest postRequest){
        boolean add = postService.add(postRequest);
        return Result.OK(add);
    }
    @PostMapping(value = "/remove")
    public Result remove(@RequestBody PostRequest postRequest){
        boolean remove = postService.remove(postRequest);
        return Result.OK(remove);
    }
    @PostMapping(value = "/update")
    public Result update(@RequestBody PostRequest postRequest){
        boolean update = postService.update(postRequest);
        return Result.OK(update);
    }
    @PostMapping(value = "/getById")
    public Result getById(@RequestBody PostRequest postRequest){
        PostRequest byId = postService.getById(postRequest);
        return Result.OK(byId);
    }
    @PostMapping(value = "/queryList")
    public Result queryList(@RequestBody PostRequest postRequest){
        List<PostRequest> postRequests = postService.queryList(postRequest);
        return Result.OK(postRequests);
    }
    @PostMapping(value = "/page")
    public Result queryPage(@RequestBody PostRequest postRequest){
        Page page = postService.queryPage(postRequest);
        return Result.OK(page);
    }
}
